#include "KnowledgeBaseMemory.h"

Factory < KnowledgeBaseMemoryInterface > KnowledgeBaseMemory::factory;

KnowledgeBaseMemory::KnowledgeBaseMemory ()
: typeRootAddress ( 0 )
, valueRootAddress ( 0 )
{
}

KnowledgeBaseMemory::~KnowledgeBaseMemory ()
{
}

KnowledgeBaseMemoryInterfacePtr KnowledgeBaseMemory::Spawn ()
{
	return factory.CreateNewObject < KnowledgeBaseMemory > ();
}

void KnowledgeBaseMemory::CheckInnocence ()
{
	assert ( factory.ObjectsCount () == 0 );
}

int KnowledgeBaseMemory::ElementsCount ()
{
	return int ( elements.size () );
}

KnowledgeBaseElementInterfacePtr KnowledgeBaseMemory::Element ( int index )
{
	return elements.at ( index );
}

void KnowledgeBaseMemory::Append ( KnowledgeBaseElementInterfacePtr element )
{
	elements.push_back ( element );
}

void KnowledgeBaseMemory::AppendTypeRoot ( KnowledgeBaseElementInterfacePtr element )
{
	typeRootAddress = int ( elements.size () );
	elements.push_back ( element );
}

void KnowledgeBaseMemory::AppendValueRoot ( KnowledgeBaseElementInterfacePtr element )
{
	valueRootAddress = int ( elements.size () );
	elements.push_back ( element );
}

int KnowledgeBaseMemory::TypeRootAddress ()
{
	return typeRootAddress;
}

int KnowledgeBaseMemory::ValueRootAddress ()
{
	return valueRootAddress;
}
